#pragma once
#include<functional>
#include<unordered_map>
#include<memory>
#include<list>
#include<string>
#include<string_view>
#include"Command.hpp"

namespace adas
{
class CmderFactory final
{
public:
    CmderFactory(void) = default;
    ~CmderFactory(void) = default;

public:
    CmderFactory(const CmderFactory&) noexcept = delete;
    CmderFactory& operator=(const CmderFactory&) noexcept = delete;

public:
    std::string ParseCommandString(std::string_view commands) const noexcept;
    void Replace(std::string& commands, std::string_view what, std::string_view with) const noexcept;
    std::list<std::function<void(PoseManage& posemanage)>> GetCmders(const std::string& commands) const noexcept;

private:
    const std::unordered_map<char, std::function<void(PoseManage& posemanage)>> cmderMap = {
        {'M', MoveCommand()}, {'R', TurnRightCommand()}, {'L', TurnLeftCommand()},
        {'B', BackCommand()}, {'F', FastCommand()}, {'Z', TurnRoundCommand()},
    };
};
}  // namespace adas
